#ifndef NP_CONNECTIONS_H
#define NP_CONNECTIONS_H

#include <map>
#include <mysql/mysql.h>
#include <config/Structures.h>

class Connections
{
public:
  static Connections* getInstance();
  void init();
  MYSQL* getConnection(const std::string& key);

private:
  void addConnection(const std::string& key, const dbinfo::DBInfo& dbinfo);
  void getDbInfo(const std::string& connString, dbinfo::DBInfo& dbInfo);

private:
  Connections();
  ~Connections();

  void closeConn();

private:
  typedef std::map<std::string, MYSQL*> ConnMap;
  typedef ConnMap::iterator ConnMapIterator;
  ConnMap m_conns;
};

#endif // NP_CONNECTIONS_H
